package priest_mathematician;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main
{
        public static void main(String [] args)
        {
                new MGame().start();
        }
}

class MGame
{
        public void start()
        {
                BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
               
                try
                {
                        String n;
                       
                        BigInteger [] threePegHanoi = evaluateHanoiThreePegs();
                        BigInteger [] fourPegHanoi = evaluateHanoiFourPegs(threePegHanoi);
                       
                        while(!(n = reader.readLine()).equals(""))
                        {
                                int number = Integer.parseInt(n);
                                       
                                System.out.println(fourPegHanoi[number]);
                        }
                }
                catch (IOException ex)
                {
                        ex.printStackTrace();
                }
        }
       
        public BigInteger [] evaluateHanoiThreePegs()
        {
                BigInteger [] input = new BigInteger[10001];
               
                // One move for only one disk.
                input[1] = new BigInteger("1");
               
                for (int i = 2; i < input.length; i++)
                {
                        input[i] = input[i - 1].add(input[i - 1]).add(new BigInteger("1"));
                }
               
                return input;
        }
       
        public BigInteger [] evaluateHanoiFourPegs(BigInteger [] hanoiThreePegs)
        {
                BigInteger [] hanoiFourPegs = new BigInteger[10001];
               
                hanoiFourPegs[1] = new BigInteger("1");
               
                BigInteger k;
               
                for (int i = 2; i < hanoiFourPegs.length ; i++)
                {
                        k = findK(hanoiThreePegs, hanoiFourPegs, i);
                       
                        hanoiFourPegs[i] = k;
                        
                        System.out.println(k);
                }
               
                return hanoiFourPegs;
        }
       
        public BigInteger findK(BigInteger [] hanoiThreePegs, BigInteger [] hanoiFourPegs, int count)
        {
                BigInteger result = new BigInteger(hanoiThreePegs[count].toString());
               
                for (int i = count - 1; i >= 1; i--)
                {
                        int hanoiThreePegCalc = Math.abs(count - i);
                       
                        BigInteger temp = hanoiFourPegs[i].add(hanoiFourPegs[i]).add(hanoiThreePegs[hanoiThreePegCalc]);
                       
                        if (temp.compareTo(result) < 1)
                        {
                                result = new BigInteger(temp.toString());
                        }
                        else
                        {
                                break;
                        }
                }
               
                return result;
        }
}

